<?php
/**
 * Created by PhpStorm.
 * User: DELL-PC
 * Date: 2018/9/5
 * Time: 8:59
 */

namespace J\MVC;


use J\Intent;

trait InvokeMethod
{
    protected function invokeIntentMethod(Intent $intent)
    {
        $action = (empty($intent->action) ? $this->get('defaultAction','Index') : $intent->action);
        $method_name =  'option' .$intent->getOption() . $action;

        if (!method_exists($this, $method_name)) return false;

        return $this->$method_name($intent);
    }

    abstract function get($key, $default = null, $withUpper = true);
}